#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

void solve1() {

	int a[101];
	int b[101] = { 0 };
	int n;
	cin >> n;

	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
	}
	for (int i = 2; i <= n; ++i) {
		for (int j = i - 1; j >= 1; --j) {
			if (a[i] > a[j])
				b[i]++;

		}
		
	}
	for (int i = 1; i <= n; ++i) {
		cout << b[i] << " ";
	}



	return;
}


void solve2() {
	int a[101];
	int temp;
	int pos = 0;
	while (1) {
		cin >> temp;
		if (temp == 0)
			break;
		a[pos++] = temp;
	}
	for (int i = pos - 1; i >= 0; --i) {
		cout << a[i] << " ";
	}

	return;
}


void solve3() {
	int n;
	cin >> n;
	int ans = 0;
	vector<int> a;
	for (int i = 1; i <= n; ++i) {
		int temp;
		cin >> temp;
		a.push_back(temp);
	}
	sort(a.begin(), a.end());

	for (int i = n - 1; i >= 1; --i) {
		for (int j = 0; j < i; ++j) {
			int flag = a[i] - a[j];

			// 定义查找范围的起始和结束迭代器
			auto start = a.begin() + j + 1;
			auto end = a.begin() + i;

			// 确保范围有效
			if (start < end) {
				// 在范围内查找 flag
				auto M_find = find(start, end, flag);
				if (M_find != end) {
					ans++;
					break;
				}
			}
		}
	}

	cout << ans;
	return;
}


void solve4() {
	int a[101];
	int n, i;
	cin >> n;
	for (i = 0; i < n; i++)
		cin >> a[i];

	sort(a, a + n);

	int count = 0;
	int l, r;
	for (i = n - 1; i >= 2; --i)
	{
		l = 0, r = i - 1;
		while (l < r)
		{
			if (a[l] + a[r] < a[i])
				++l;
			else if (a[l] + a[r] > a[i])
				--r;
			else
			{
				count++;
				break;
			}
		}
	}
	cout << count;
	
}



void solve5() {
	int n;
	cin >> n;
	vector<int> tmp;
	tmp.push_back(n);
	while (n != 1) {
		if (n % 2 == 0) {
			n /= 2;
			tmp.push_back(n);
		}

		else {
			n = n * 3 + 1;
			tmp.push_back(n);
		}
	}
	auto qwer = tmp.end() - 1;

	while (qwer != tmp.begin()) {
		cout << *qwer << " ";
		--qwer;
	}
	cout << *qwer << " ";
	return;
}

int main() {

	//solve1();
	//solve2();
	//solve3();
	//solve4();
	solve5();


	return 0;
}